package site;

import java.util.ArrayList;
import java.util.Date;

import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateful
public class ReunionManager {
	
	private static int ident ;
	
	@PersistenceContext
	EntityManager em;
	public void ajouterReunion(String objet, int jj, int mm,
			int aaaa, String commentaire , String lieuReunion) {
		
			@SuppressWarnings("deprecation")
			Date dateReunion = new Date (aaaa,mm,jj);
			Reunion reunion = new Reunion ();
			reunion.setObjet(objet);
			reunion.setDateReunion(dateReunion);
			reunion.setCommentaire(commentaire);
			reunion.setLieuReunion(lieuReunion);
			em.persist(reunion);
			ident = reunion.getIdent();
	}
	
	public void ajouterCompteRenduReunion (String compteRendu) {
		
		Reunion reunion = em.find(Reunion.class, ident );
		reunion.setCompteRendu(compteRendu);
	
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<Integer> listeIdentReunion() {
        return (ArrayList<Integer>) em.createQuery("SELECT r.ident FROM Reunion r").getResultList() ;
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<String> listeObjet() {
        return (ArrayList<String>) em.createQuery("SELECT r.Objet FROM Reunion r").getResultList() ;
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<Date> listeDate() {
        return (ArrayList<Date>) em.createQuery("SELECT r.dateReunion FROM Reunion r").getResultList() ;
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<String> listeCommentaire() {
        return (ArrayList<String>) em.createQuery("SELECT r.commentaire FROM Reunion r").getResultList() ;
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<String> listeLieu() {
        return (ArrayList<String>) em.createQuery("SELECT r.lieuReunion FROM Reunion r").getResultList() ;
	}

	@SuppressWarnings("unchecked")
	public ArrayList<String> listeCompteRendu() {
        return (ArrayList<String>) em.createQuery("SELECT r.compteRendu FROM Reunion r").getResultList() ;
	}
}